﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Pulog.Models.Post>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <%--<h2>Show</h2>

    <fieldset>
        <legend>Fields</legend>
        <p>
            postID:
            <%= Html.Encode(Model.postID) %>
        </p>
        <p>
            title:
            <%= Html.Encode(Model.title) %>
        </p>
        <p>
            pubTime:
            <%= Html.Encode(String.Format("{0:g}", Model.pubTime)) %>
        </p>
        <p>
            authorID:
            <%= Html.Encode(Model.authorID) %>
        </p>
        <p>
            views:
            <%= Html.Encode(Model.views) %>
        </p>
        <p>
            property:
            <%= Html.Encode(Model.property) %>
        </p>
        <p>
            categoryID:
            <%= Html.Encode(Model.categoryID) %>
        </p>
        <p>
            sticky:
            <%= Html.Encode(Model.sticky) %>
        </p>
        <p>
            content:
            <%= Html.Encode(Model.content) %>
        </p>
        <p>
            password:
            <%= Html.Encode(Model.password) %>
        </p>
        <p>
            slug:
            <%= Html.Encode(Model.slug) %>
        </p>
    </fieldset>
    <p>

        <%=Html.ActionLink("Edit", "Edit", new { id=Model.postID }) %> |
        <%=Html.ActionLink("Back to List", "Index") %>
    </p>
    <%Html.RenderPartial("~/Views/Home/ShowPostComments.ascx",Model.Comments); %>

-------------------------------------------------------------------------------------------------------------------------------------------
--%>
    <script type="text/javascript" src="../../Scripts/jquery.scrollTo-1.4.2-min.js"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            //            $.getJSON("<%=ResolveUrl("~/Json/Posts")%>", null, function(data) {
            //                buildPostList(data);
            //            });
            //$("a").click(function(event) {
            //  alert("Thanks for visiting!");
            //});
            $("#submitComment").click(function() {
                var c = $("form").serialize();
                $.ajax({
                    type: "POST",
                    data: c,
                    //dataType: "json",
                    url: "<%=ResolveUrl("~/Posts/AddComment/") %>",
                    success: function(response){
                        // clear commentParentID
                        $("#CommentParentID").val("");
                        // make submit comment form visible again
                        $("#submitCommentFieldset").removeClass("replyCommentFieldset");
                        $("#addComment").appendTo("#comments");
                        //
                        $('div.boxcomments').load("<%=ResolveUrl("~/Posts/ShowPostComments/") %>"+$('#PostID').val(),
                        function(responseText, textStatus, XMLHttpRequest){
                            if(response >= 0)
                            {
                                $(window).scrollTo('div#Comment'+response);
                                $('div#Comment'+response).effect("highlight", {}, 8000);
                            }
                        });
                        // clear textboxes
                        //   $("input[type='text'],#CommentContent").each(function(){
                        //   $(this).attr("value",'');
                        //   });
                        $("#CommentContent").attr("value",'');
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown){
                        //alert("An error occured, please try again.");
                        alert(XMLHttpRequest.responseText);
                    },
                    complete: function(XMLHttpRequest, textStatus){
                        $("#submitComment").removeAttr("disabled");
                        $("#submitComment").attr("value", "写好了，加上去");
                    }
                });
            });
            
            $("#submitComment").ajaxSend(function(r,s){  
                $(this).attr("disabled", "true");
                $(this).attr("value", "Submitting...Please wait...");
            })
//            .ajaxStop(function(r,s){
//                
//            });
            //        $(function() {
            //             $('#monthList').change(function() {
            //                $.getJSON("<%=ResolveUrl("~/Json/Posts")%>" + this.value, null, function(data) {
            //                    buildPostList(data);
            //                });
            //             });
            
            
        });
        function ReplyComment(commentID,numericID) {
            $("#addComment").appendTo(commentID);
            $("#CommentParentID").val(numericID);
            $("#submitCommentFieldset").attr("class", "replyCommentFieldset");
            return true;
        };
        
     </script>


    <article class="post">
                <h3><a href="/Posts/Show/<%=ViewData.Model.postID.ToString()%>"><%=ViewData.Model.title%></a>
            </h3>
        
        <footer class="postmeta">作者:<%=Model.User.userName %> 发表于:<%=ViewData.Model.pubTime.ToString("yyyy年MM月dd日")%> -- <%=Helper.GetDateDifference(ViewData.Model.pubTime)%> | 分类: <a href="/Category/<%=ViewData.Model.Category.categoryName%>">
        <%=ViewData.Model.Category.categoryName%></a> | <a href="/Posts/Show/<%=Model.postID.ToString()%>#comments">Comments: <%=Model.Comments.Count %></a> | Views: <%=Model.views %> | &nbsp; <!-- AddThis Button BEGIN -->
        <div class="addthis_toolbox addthis_default_style">
        <a href="http://www.addthis.com/bookmark.php?v=250&amp;username=starcub" class="addthis_button_compact">Share</a>
        </div>
        <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=starcub"></script>
        <!-- AddThis Button END -->

<%--        | Tags: <%foreach (Pulog.Models.PostTag t in ViewData.Model.PostTags.ToList())
        {%>
            <a href="/Tags/<%= t.Tag.TagName %>"><%= t.Tag.TagName %></a>,<%} %>--%>
        </footer>

            <p>
                <%=ViewData.Model.content%>
            </p>

        <%if (Request.IsAuthenticated)
          { %>
        <p>
            <%=Html.ActionLink("Edit", "Edit", new { id = Model.postID })%> |
            <%=Html.ActionLink("Back to List", "Index")%>
        </p>
        <%} %>
    </article>
    <div id="comments">
        <% Html.RenderPartial("PostComments",Model); %>
        <% if (Model.property != 1)
           {%>
                <div id="addComment">
                    <% Html.RenderPartial("SubmitComment"); %>
                </div>
        <%} %>
        <%else
            { %>
                <div id="noComment">
                    <hr />
                    <span>Commenting is disabled.</span>
                </div>
        <%} %>
    </div>
    



</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
    <title><%=ViewData.Model.title%> - <%=Helper.BlogName %> : <%=Helper.BlogDescription %></title>
    <meta name="description" content="<%=ViewData.Model.title %> <%=Helper.BlogName %> <%=Helper.BlogDescription %>" />
</asp:Content>

